package com.example.test.exception;



import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;

public class MyException extends RuntimeException {

    private Logger logger = Logger.getLogger("exception");

    {
        logger.setLevel(Level.FINE);   // 设置等级
        logger.setFilter(record -> {
            return record.getMessage().startsWith("start"); // 设置过滤器
        });
        try {
            FileHandler handler = new FileHandler("%h/my.log",50000,3,true);   // 格式化器
            handler.setFormatter(null);
            logger.addHandler(handler);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }



    public MyException() {

    }

    public MyException(String message) {
        super(message);
    }
}
